package com.seawaterbt.cloud.serverribbon.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.seawaterbt.cloud.serverribbon.service.HiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class HiServiceImpl implements HiService {

    @Autowired
    private RestTemplate restTemplate;

    @Override
    @HystrixCommand(fallbackMethod = "hiError")
    public String invokeServerHi(String name) {
        return restTemplate.getForObject("http://SERVER-HI/hi?name="+name,String.class);
    }

    public String hiError(String name){
        return "name="+name+"    Sorry error!";
    }
}
